import React, {Component} from 'react';
import {
    StyleSheet,
    Text,
    View,
    Image,
    Dimensions,
    ListView,
    TouchableOpacity,
    Platform
} from 'react-native';
import dismissKeyboard from 'react-native/Libraries/Utilities/dismissKeyboard'

const {height, width} = Dimensions.get('window');
export default class OverLayTakingPictures extends Component {
    constructor(props) {
        super(props);
        this.state = {

        }
    };
    pickSingleWithCamera=()=>{
        if(this.props.pickSingleWithCamera){
            this.props.pickSingleWithCamera('takingPictures')
        }
    };
    openPicLib=()=>{
        if(this.props.openPicLib){
            this.props.openPicLib('photoAlbum')
        }
    };

    deleteOverlay=()=>{
        if(this.props.deleteOverlay){
            this.props.deleteOverlay('deleteOverlay')
        }
    };

    render() {
        dismissKeyboard();
        return (
            <View style={{width:width-10, alignItems: 'center',marginLeft:5}}>
                <TouchableOpacity
                    activeOpacity={0.8}
                    style={[styles.overlay,{borderTopRightRadius:10, borderTopLeftRadius:10}]}
                    onPress={() => this.pickSingleWithCamera()}>
                    <Text style={[styles.PopMsg,{color:this.props.ID=='suppliers' ? suppliersThemeColor : PurchaserThemeColor,}]}>拍照</Text>
                </TouchableOpacity>
                <View style={{height:0.5,backgroundColor:'#cfcfcf',width:width-10}}/>
                <TouchableOpacity
                    activeOpacity={0.8}
                    style={[styles.overlay,{borderBottomLeftRadius:10, borderBottomRightRadius:10}]}
                    onPress={() => this.openPicLib()}>
                    <Text style={[styles.PopMsg,{color:this.props.ID=='suppliers' ? suppliersThemeColor : PurchaserThemeColor,}]}>从手机相册中选择</Text>
                </TouchableOpacity>
                <TouchableOpacity
                    activeOpacity={0.8}
                    style={styles.overlay1}
                    onPress={()=>this.deleteOverlay()}>
                    <Text style={[styles.PopMsg,{color:'#000000'}]}>取消</Text>
                </TouchableOpacity>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#f0f0f0'
    },
    PopMsg:{
        textAlign:'center',
        fontSize:15,
    },
    overlay1:{
        height:44,
        width:width-10,
        borderRadius:10,
        alignItems:'center',
        justifyContent:'center',
        backgroundColor:'#ffffff',
        marginTop:5,
        marginBottom:10
    },
    overlay:{
        height:44,
        width:width-10,
        alignItems:'center',
        justifyContent:'center',
        backgroundColor:'#ffffff'
    },
});
